package com.zyk.leetcode;

import java.util.Arrays;

/**
 * @author zhangsan
 * @date 2021/4/12 13:34
 */
public class M0508 {

    // https://leetcode-cn.com/problems/draw-line-lcci/
    public static int[] drawLine(int length, int w, int x1, int x2, int y) {
        int[] ans=new int[length];
        int low=(y*w+x1)/32;
        int high=(y*w+x2)/32;
        for(int i=low;i<=high;i++){
            ans[i]=-1;
        }
        ans[low]=ans[low]>>>x1%32;
        ans[high]=ans[high]&Integer.MIN_VALUE>> x2 % 32;
        return ans;
    }


    // for test
    public static void main(String[] args) {
        int length = 15, w = 96, x1 = 81, x2 = 95, y = 1;
        int[] ans = drawLine(length, w, x1, x2, y);
        System.out.println(Arrays.toString(ans));
    }

}
